package com.yiyang.exception;

import com.yiyang.domain.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobleException {
    @ExceptionHandler(Exception.class)
    public Result exceptionHandler(Exception e){
        e.printStackTrace();
        return Result.fail(999,e.getMessage());
    }

    @ExceptionHandler(ServiceException.class)
    public Result serviceExceptionHandler(ServiceException e){
        e.printStackTrace();
        return Result.fail(e.getCode(),e.getMessage());
    }
}
